/**
 * 
 */
package genericos.dao.hibernate;

import genericos.dao.exeptions.PersistanceException;
import genericos.dao.exeptions.PersistenceServiceException;

import java.io.Serializable;

import org.hibernate.Session;
import org.hibernate.criterion.Order;

/**
 * @author PUSDERKIS
 *
 */
public interface UniversalHibernateDAO {
	
	/**
	 * @throws PersistanceException in case of error.
	 * @return the hibernate session.
	 */
	Session getHibernateSession() throws PersistanceException;
	
	/**
	 * Carga un objeto en base al ID.
	 * @param clz la clase.
	 * @param id el id del objeto.
	 * @return el objeto.
	 * @throws PersistanceException En caso de error.
	 */
	Object load(@SuppressWarnings("rawtypes") Class clz,Serializable id) throws PersistanceException;
	
	/**
	 * Used by the base DAO classes but here for your modification Load object
	 * matching the given key and return it.
	 */
	Object get(@SuppressWarnings("rawtypes") Class refClass, Serializable key)
			throws PersistenceServiceException;
	
	/**
	 * Return all objects related to the implementation of this DAO with no
	 * filter.
	 */
	public java.util.List findAll(Class clazz)
			throws PersistenceServiceException;

	/**
	 * Return all objects related to the implementation of this DAO with no
	 * filter.
	 */
	public java.util.List findAll(Class clazz, Order defaultOrder)
			throws PersistenceServiceException;
	
	/**
	 * Used by client DAO classes. This call forces a syncronization process
	 * between <br>
	 * session state and the database (NO COMMIT!). See Hibernate Documentation
	 * for a more <br>
	 * detailed description about flushing process and when to call it.
	 * 
	 * @throws PersistenceServiceException
	 */
	public void flush() throws PersistenceServiceException;
	
	
	public void save(Object obj) throws PersistenceServiceException;
	
	public void saveOrUpdate(Object obj) throws PersistenceServiceException;
}
